package com.sanjiahantang.youjiarole.module.me.order.models.impl;

import android.content.Context;

import com.sanjiahantang.youjiarole.base.BaseBean;
import com.sanjiahantang.youjiarole.base.CallBack;
import com.sanjiahantang.youjiarole.config.ConfigValue;
import com.sanjiahantang.youjiarole.http.BaseDelegate;
import com.sanjiahantang.youjiarole.http.OkHttpClientManager;
import com.sanjiahantang.youjiarole.module.common.beans.StringBean;
import com.sanjiahantang.youjiarole.module.me.address.beans.AddressBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.OrderResponseBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.OrderTakeNumberResponseBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.OrderTakeResponseBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.OrderYuEPayResponseBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.RequireOrderBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.Service3PartBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.ServiceListBean;
import com.sanjiahantang.youjiarole.module.me.order.beans.ShopListBean;
import com.sanjiahantang.youjiarole.module.me.order.models.IOrderModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/25.
 */

public class  OrderModel implements IOrderModel {

    @Override
    public void searchPriceDesignPhoneForRole(final Context context, Map<String, String> param, final CallBack<RequireOrderBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/project/phone/plan/searchPriceDesignPhoneForRole",
                param,new BaseDelegate.ResultCallback<RequireOrderBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(RequireOrderBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

//    @Override
//    public void servieceOrdeList(final Context context, Map<String, Object> param, final CallBack<ServiceListBean> callBack) {
//        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/findOrderSQLForServicePhone",
//                param,new BaseDelegate.ResultCallback<ServiceListBean>() {
//
//                    @Override
//                    public void onError(Request request, Object tag, Exception e) {
//                        callBack.onFailure(e.getMessage());
//                    }
//
//                    @Override
//                    public void onResponse(ServiceListBean response, Object tag) {
//                        callBack.onSuccess(response,context, tag);
//                    }
//                });
//
//    }

    @Override
    public void searchUserAddressOrder(final Context context, Map<String, String> params, final CallBack<AddressBean> callBack) {

        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/role/address/searchRoleAddressOrder",
                params,new BaseDelegate.ResultCallback<AddressBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(AddressBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void createOrderForMallCommon(final Context context, Object param, final CallBack<OrderResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForMallCommon",
                param,new BaseDelegate.ResultCallback<OrderResponseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderResponseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void payGoodsOrderPhone(final Context context, Object requestBean, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/payGoodsOrderPhone",
                requestBean,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void loadOrderList(final Context context, Map<String, Object> params, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/findOrderSQLForGoodsPhone", params,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });


    }


    //未接单列表
    @Override
    public void loadOrderTakeList(final Context context, Map<String, Object> param, final CallBack<OrderTakeResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/roleSign/searchRequireList", param,
                new BaseDelegate.ResultCallback<OrderTakeResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderTakeResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }


    @Override
    public void operatorState(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack,String orderCode) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/operatorState", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                },orderCode);
    }

    @Override
    public void cancelOrderPhone(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/cancelOrderPhone", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void initSearchRequire(final Context context, Map<String, Object> param, final CallBack<OrderTakeNumberResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/roleSign/initSearchRequire", param,
                new BaseDelegate.ResultCallback<OrderTakeNumberResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderTakeNumberResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void searchRequireOverList(final Context context, Map<String, Object> param, final CallBack<OrderTakeResponseBean> callBack) {

        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/roleSign/searchRequireOverList", param,
                new BaseDelegate.ResultCallback<OrderTakeResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderTakeResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void searchGoodsRaForCode(final Context context, Map<String, Object> param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForMallCommon", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveInvoiceInfoPhoneForRole(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/invoice/saveInvoiceInfoPhoneForRole", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void findOrderExpressInfo(final Context context, Map<String, Object> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/express/findOrderExpressInfo", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void searchServiceOrder(final Context context, Map<String, String> param, final CallBack<ServiceListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/searchServiceRaForCode", param,
                new BaseDelegate.ResultCallback<ServiceListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ServiceListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void searchPriceDesignPhoneForCustomer(final Context context, Map<String, String> param, final CallBack<RequireOrderBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/project/role/plan/searchPriceDesignPhoneForRole",
                param,new BaseDelegate.ResultCallback<RequireOrderBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(RequireOrderBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void createOrderForDesign(final Context context, Map<String, Object> param, final CallBack<Service3PartBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForDesign",
                param,new BaseDelegate.ResultCallback<Service3PartBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(Service3PartBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void getCheckCodeGood(final Context context, Object param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/getCheckCodeGoods", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveBankPayGoods(final Context context, Object data, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/saveBankPayGoods", data,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void createGoodsPayNumber(final Context context, Object data, final CallBack<OrderYuEPayResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createGoodsPayNumber", data,
                new BaseDelegate.ResultCallback<OrderYuEPayResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderYuEPayResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void goodsBalancePay(final Context context, Object bean, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/goodsBalancePay", bean,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

}
